home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Games / Xconq 7.0d16 / Xconq 7.0d16 src / mac / mactextldef.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-14  |  1.6 KB  |  55 lines  |  [TEXT/KAHL]

  1. /* Minimal text LDEF, no fancy features, stripped down from a version by Adam Winer (?). */
  2.  
  3. /* Spacing parameters. */
  4.  
  5. #define kLeftOffset    2
  6. #define kTopOffset    0
  7.  
  8. pascal void
  9. main(short listmsg, Boolean selected, Rect *listrectptr, Cell listcell,
  10.      short listdataoffset, short listdatalength, ListHandle listhandle)
  11. {
  12.     FontInfo fontInfo;
  13.     ListPtr listptr;
  14.     SignedByte hStateList, hStateCells;
  15.     Ptr celldata;
  16.     short leftdraw, topdraw, wayleft;
  17.     
  18.     /* Lock and dereference the list and cell data handles. */    
  19.     hStateList = HGetState((Handle) listhandle);
  20.     HLock((Handle) listhandle);
  21.     listptr = *listhandle;
  22.     hStateCells = HGetState(listptr->cells);
  23.     HLock(listptr->cells);
  24.     celldata = *(listptr->cells);
  25.     /* Decipher the desired action on the list. */
  26.     switch (listmsg) {
  27.       case lInitMsg:
  28.           /* We don't need any initialization. */
  29.           break;
  30.       case lDrawMsg:
  31.         EraseRect(listrectptr);
  32.           if (listdatalength > 0) {
  33.               /* Determine starting point for drawing. */
  34.               wayleft = listcell.h * listptr->cellSize.h + listptr->rView.left;
  35.               leftdraw = wayleft + listptr->indent.h + kLeftOffset;
  36.               topdraw = listrectptr->top + listptr->indent.v + kTopOffset;
  37.             GetFontInfo(&fontInfo);
  38.             MoveTo(leftdraw, topdraw + fontInfo.ascent);
  39.             TextFace(0);
  40.             DrawText(celldata, listdataoffset, listdatalength);
  41.           }
  42.         if (!selected) break;
  43.         /* Fall through to draw selected cell in hilite color. */
  44.       case lHiliteMsg:
  45.           /* Do hilite color. */
  46.           BitClr(&HiliteMode, pHiliteBit);
  47.           InvertRect(listrectptr);
  48.           break;
  49.       case lCloseMsg:
  50.           break;
  51.     }
  52.     HSetState(listptr->cells, hStateCells);
  53.     HSetState((Handle) listhandle, hStateList);
  54. }
  55.